import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

// 获取学习测评内容
interface SearchForm {
  status: number;
  msg: string;
  data: {
    pageIndex: number;
    pageCount: number;
    totalCount: number;
    pageSize: number;
    keyword: string;
    list: [
      {
        learningAssessmentId: string;
        menuId: string;
        menuName: string;
        moduleId: string;
        moduleName: string;
        questionType: string;
        title: string;
        answerA: string;
        answerB: string;
        answerC: string;
        answerD: string;
        answerE: string;
        trueAnswer: string;
        remark: string;
        userId: string;
        createTime: "2023-04-25T08:23:44.073Z";
      }
    ];
  };
  success: boolean;
}
interface SearchLoad {
  status: number;
  msg: string;
  data: {
    pageIndex: number;
    pageCount: number;
    totalCount: number;
    pageSize: number;
    keyword: string;
    list: [
      {
        resourceId: string;
        menuId: string;
        menuName: string;
        moduleId: string;
        moduleName: string;
        resourceType: 1;
        resourceName: string;
        resourceAbstract: string;
        url: string;
        fileType: string;
        fileSize: number;
        state: string;
        uploadUser: string;
        share: boolean;
        isShow: boolean;
        createTime: string;
      }
    ];
  };
  success: boolean;
}

interface subAssessment {
  ver: string;
  success: boolean;
  data: string;
  cmd: string;
  status: number;
  msg: string;
}

interface GetAllRemark {
  status: number;
  msg: string;
  data: {
    pageIndex: number;
    pageCount: number;
    totalCount: number;
    pageSize: number;
    keyword: string;
    list: [
      {
        menuId: string;
        menuName: string;
        answerType: string;
        answerTest: string;
        answerCode: string;
        remark: string;
      }
    ];
  };
  success: boolean;
}

export const GetLearningAssessment = (data: object) => {
  return http.request<SearchForm>(
    "post",
    baseUrlApi("/LearningAssessment/GetLearningAssessment"),
    {
      data
    }
  );
};
// 添加题目
export const UpdateLearningAssessment = (data: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/LearningAssessment/UpdateLearningAssessment"),
    {
      data
    }
  );
};
// 删除题目
export const DeleteLearningAssessment = (params: string) => {
  return http.request<any>(
    "get",
    baseUrlApi("/LearningAssessment/DeleteLearningAssessment?" + params)
  );
};

// 获取任务说明管理列表
export const GetAllTaskRemark = (params: string) => {
  return http.request<GetAllRemark>(
    "get",
    baseUrlApi("/TaskRemark/GetAll?" + params)
  );
};

// 修改or添加任务说明
export const UpdateTaskRemark = (data: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/TaskRemark/UpdateTaskRemark"),
    {
      data
    }
  );
};
// 删除任务说明
export const DeleteTaskRemark = (params: string) => {
  return http.request<subAssessment>(
    "get",
    baseUrlApi("/TaskRemark/DeleteTaskRemark?" + params)
  );
};

// 获取资源列表
export const LoadGetResource = (data: object) => {
  return http.request<SearchLoad>(
    "post",
    baseUrlApi("/LoadResources/GetResource"),
    { data }
  );
};

// 添加or修改资源
export const UpdateResource = (data: object) => {
  return http.request<subAssessment>(
    "post",
    baseUrlApi("/LoadResources/UpdateResource"),
    { data }
  );
};

// 删除资源管理
export const DeleteResource = (params: string) => {
  return http.request<subAssessment>(
    "get",
    baseUrlApi("/LoadResources/DeleteResource?" + params)
  );
};
